Conditions | 1 |
Paths | 1 |
Total Lines | 81 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | // Base path --> assets/html |
||
21 | $(document).ready(function() { // When document is ready |
||
22 | ipcRenderer.send('app:debug', "Document is ready"); |
||
23 | |||
24 | startup(); |
||
25 | |||
26 | // Button/Toggle special menu items |
||
27 | $('#navButtonExtendedmenu').click(function() { |
||
28 | ipcRenderer.send('app:debug', "#navButtonExtendedmenu was clicked"); |
||
29 | $('#navButtonExtendedmenu').toggleClass('is-active'); |
||
30 | $('.is-specialmenu').toggleClass('is-hidden'); |
||
31 | }); |
||
32 | |||
33 | // Window minimize button |
||
34 | $('#navButtonMinimize').click(function() { |
||
35 | ipcRenderer.send('app:debug', "#navButtonMinimize was clicked"); |
||
36 | remote.getCurrentWindow().minimize(); |
||
37 | }); |
||
38 | |||
39 | // Window exit button |
||
40 | $('#navButtonExit').click(function() { |
||
41 | ipcRenderer.send('app:debug', "#navButtonExit was clicked"); |
||
42 | remote.getCurrentWindow().close(); |
||
43 | }); |
||
44 | |||
45 | // Assign [ESC] to close message/modal |
||
46 | $(document).keyup(function(event) { |
||
47 | if (event.keyCode === 27) { |
||
48 | ipcRenderer.send('app:debug', "Used [ESC] key, {0}".format(event.keyCode)); |
||
49 | if ($('#swMessageWhois').hasClass('is-active')) { |
||
50 | $('#swMessageWhoisClose').click(); |
||
51 | } else if ($('.notification')) { |
||
52 | $('.notification:not(.is-hidden)').addClass('is-hidden'); |
||
53 | if ($('#swTableWhoisInfo:not(.is-hidden)')) { |
||
54 | $('#swTableWhoisInfo').addClass('is-hidden'); |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | }); |
||
59 | |||
60 | // Prevent drop redirect |
||
61 | $(document).on('drop', function(event) { |
||
62 | ipcRenderer.send('app:debug', "Preventing drag and drop redirect"); |
||
63 | event.preventDefault(); |
||
64 | return false; |
||
65 | }); |
||
66 | |||
67 | // Prevent drag over redirect |
||
68 | $(document).on('dragover', function(event) { |
||
69 | event.preventDefault(); |
||
70 | return false; |
||
71 | }); |
||
72 | |||
73 | // Toggle devtools |
||
74 | $('#navTabDevtools').click(function() { |
||
75 | remote.getCurrentWindow().toggleDevTools(); |
||
76 | ipcRenderer.send('app:debug', "#navTabDevtools was clicked"); |
||
77 | }); |
||
78 | |||
79 | // Toggle between tabs |
||
80 | $('section.tabs ul li').click(function() { |
||
81 | var tabName = $(this).attr('data-tab'); |
||
82 | |||
83 | if (tabName != '#') { |
||
84 | $('section.tabs ul li').removeClass('is-active'); |
||
85 | $('div.container .tab-content').removeClass('current'); |
||
86 | |||
87 | $(this).addClass('is-active'); |
||
88 | $("#" + tabName).addClass('current'); |
||
89 | } |
||
90 | ipcRenderer.send('app:debug', "#section.tabs switched to data tab, {0}".format(tabName)); |
||
91 | }); |
||
92 | |||
93 | // Delete notifications |
||
94 | $('.delete').click(function() { |
||
95 | ipcRenderer.send('app:debug', ".delete (notifications) was clicked"); |
||
96 | var notificationId = $(this).attr('data-notif'); |
||
97 | |||
98 | $('#' + notificationId).addClass('is-hidden'); |
||
99 | }); |
||
100 | |||
101 | }); |
||
102 | |||
130 |